package javabase.base.client10.deep;

/**
 * @author chengshuai
 * @date 2021/5/2 13:16
 */
public class Client1 {

    /**
     * 构造方法实现深拷贝
     * @param args
     */
    public static void main(String[] args) {
        Address address = new Address("杭州", "中国");
        User user = new User("大山", address);
        // 调用构造函数时进行深拷贝
        User copyUser = new User(user.getName(), new Address(address.getCity(), address.getCountry()));
        // 修改源对象的值
        user.getAddress().setCity("深圳");
        System.out.println(user);
        System.out.println(copyUser);
    }

}
